#include<stdio.h>
#include<algorithm>
using namespace std;
const int maxn=100;
int main()
{
	int n,x[maxn],y[maxn],r[maxn],dp[maxn];
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d%d%d",&x[i],&y[i],&r[i]);
	}
	int sum=0;
	for(int i=0;i<n;i++){
		dp[i]=r[i]*r[i];
		for(int j=0;j<i;j++){
			if((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])>=(r[i]+r[j])*(r[i]+r[j]))
				dp[i]=dp[j]+r[j]*r[j];
			else if(r[i]<r[j])  
				dp[i]=dp[i]-r[i]*r[i]+r[j]*r[j]; 
		}
		printf("%d\n",dp[i]);
		sum=max(sum,dp[i]);
	}
	printf("%d",sum);
	return 0;
}
